import { Component, OnInit, Injector } from '@angular/core';
import { NgZorroPageBaseComponent } from '../../core/ng-zorro-page-base-component/ng-zorro-page-base-component.component';
import { BaseComponentConfig, CustomNavigation, ElementShowType, NavigatType } from '../../core/model/BaseComponentConfig';
import { ArSystemFormControl, SystemFormControl, FieldType, LoadRemoteDataType } from '../../core/model/CommonDto';
import { async } from 'q';

@Component({
  selector: 'app-student-join-class-request',
  templateUrl: './student-join-class-request.component.html',
  styleUrls: ['./student-join-class-request.component.scss']
})
export class StudentJoinClassRequestComponent extends NgZorroPageBaseComponent implements OnInit {

  constructor(
    injector: Injector
  ) {
    super(injector,
      new BaseComponentConfig(
        "TeacherInfo/GetClassInfoToStudent",
        "",
        "",
        "",
        "",
        "id",
        "",
        "学生加入课程申请",
        new Array<CustomNavigation>(
          new CustomNavigation('通过', '', ElementShowType.TableOperation, 'anticon anticon-bars', NavigatType.Model, 'pass'),
          // new CustomNavigation('拒绝', '', ElementShowType.TableOperation, 'anticon anticon-bars', NavigatType.Model, 'reject'),
        ),
        '',
        { Edit: false, Dell: false }
      ), new ArSystemFormControl([
        new SystemFormControl("userId", "用户ID", FieldType.Text, true, 30, 0, "", "", false, null, LoadRemoteDataType.LoadAll, false, false, false),
        new SystemFormControl("personName", "学生姓名", FieldType.Text, false, 0, 0, "", "", false, null, LoadRemoteDataType.LoadAll, true, true, false),
        new SystemFormControl("classInfoId", "班级ID", FieldType.Number, false, 30, 0, "", "", false, null, LoadRemoteDataType.LoadAll, false, false, false),
        new SystemFormControl("className", "班级名称", FieldType.Text, false, 0, 0, "", "", false, null, LoadRemoteDataType.LoadAll, true, true, false),
        new SystemFormControl("applyType", "状态", FieldType.Number, false, 0, 0, "", "", false, null, LoadRemoteDataType.LoadAll, false, false, false),
        new SystemFormControl("time", "申请时间", FieldType.Text, false, 300, 0, "", "", false, null, LoadRemoteDataType.LoadAll, true, true, false),
        new SystemFormControl("id", "ID", FieldType.Number, false, 300, 0, "", "", false, null, LoadRemoteDataType.LoadAll, false, false, false),
      ]));
  }

  /**
   * 获取空的实例
   */
  getNewEntity(): any {
    return {};
  }
  /**
 * 子窗体显示
 * @param entity 实体
 * @param tag 标识
 */
  async showModalForComponent(entity: any, tag: any) {
    this.nzModalService.confirm({
      nzTitle: "学生申请加入课程",
      nzContent: '是否要通过申请？',
      nzOnOk: async () => {
        await this.httpService.post<any>(`TeacherInfo/ExaminationStduent`, { studentId: entity.userId, classInfoId: entity.classInfoId, applyType: 2 });
        this.getEntityList();
      }
    });

  }
}
